<template>
  <el-dialog
    title="试题审核"
    :visible.sync="publishVisible"
    width="35%"
    :before-close="close"
  >
  <el-radio v-model="form.chkState" :label="1">通过</el-radio>
  <el-radio v-model="form.chkState" :label="2">拒绝</el-radio>
  <br><br>
  <el-input type="textarea" v-model="form.chkRemarks" placeholder="请输入审核意见"></el-input>
  <br><br><br><br>
  <div style="text-align: right">
  <el-button @click="clear">取消</el-button>
  <el-button type="primary" @click="submit">确认</el-button></div>
  </el-dialog>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'
export default {
  props: {
    publishVisible: {
      type: Boolean,
      required: true
    },
    id: {
      required: true
    }
  },
  data () {
    return {
      form: {
        id: null,
        chkState: 1,
        chkRemarks: ''
      }
    }
  },
  methods: {
    close () {
      this.$emit('update:publishVisible', false)
      this.clear()
    },
    clear () {
      this.form = {
        id: null,
        chkState: 1,
        chkRemarks: ''
      }
    },
    async submit () {
      if (this.form.chkRemarks === '') {
        return this.$message({
          message: '请输入审核意见',
          type: 'warning'
        })
      }
      this.form.id = this.id
      await choiceCheck(this.form)
      this.clear()
      this.close()
      this.$emit('list')
    }
  }
}
</script>

<style scoped lang='less'>
</style>
